import SearchDao from '../dao/SearchDao'
// import RedisUtil from '../../../common/RedisUtil'

class SearchService {
  static SearchService: SearchService = new SearchService()
  async addOrUpdateHistoryKeyword(historyKeyword: string) {
    const dbHs = await SearchDao.searchHistoryKeywords(historyKeyword);
    if(dbHs){
       const result:[{affectedRows:number},any] =  await SearchDao.updateHistoryKeywordCount(historyKeyword);
       return result[0].affectedRows;
    } else {
      const result =   SearchDao.saveHistoryKeyWords(historyKeyword);
      return 1;
    }
  }
  async SearchKeywords(key:string){
    return await SearchDao.searchKeywords(key);
  }
  // 搜索发现
  async searchDecovery(){
    return SearchDao.searchDecovery();
  }
}
export default SearchService.SearchService
